-
-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert C-style stat arrays for game objects to std::vector
#3616
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Pavel Solodovnikov <[email protected]>
Signed-off-by: Pavel Solodovnikov <[email protected]>
Signed-off-by: Pavel Solodovnikov <[email protected]>
Signed-off-by: Pavel Solodovnikov <[email protected]>
Signed-off-by: Pavel Solodovnikov <[email protected]>
Signed-off-by: Pavel Solodovnikov <[email protected]>
Signed-off-by: Pavel Solodovnikov <[email protected]>
Signed-off-by: Pavel Solodovnikov <[email protected]>
Signed-off-by: Pavel Solodovnikov <[email protected]>
There were many places across the WZ code base, which happened to calculate various object stats by accessing the global stats arrays directly, although, there are some utility functions (at least, for `DROID` class) to get these conveniently. Replace such occurrences by these getter functions for `DROID` instances. Signed-off-by: Pavel Solodovnikov <[email protected]>
The `%zu` format specifier should be nowadays supported by both MSVC and GCC/Clang, so use this instead of casting to unsigned int. Signed-off-by: Pavel Solodovnikov <[email protected]>
There were some places where these functions were called several times in a row, this can be easily optimized by saving the result to a variable. Signed-off-by: Pavel Solodovnikov <[email protected]>
Signed-off-by: Pavel Solodovnikov <[email protected]>
The old `STATS_DEALLOC` and `ALLOC_STATS` macros are not needed anymore. Rename `ALLOC_STATS_VECTOR` to just `ALLOC_STATS`. Signed-off-by: Pavel Solodovnikov <[email protected]>
Could change some of the for loops to use size_t in the init expression. This is rather inconsistent throughout the whole codebase so it's not a big issue. Unless I missed something this looks good to me. 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patchset aims to refactor stat vectors by replacing C-style raw pointer arrays by
std::vector<SMTH_STATS>
. The main benefit is that this prevents the use of pointer arithmetic tricks to access array elements (which was quite common before the change).Also, many places have used an exploded version of getting the stats by directly accessing the stats arrays, although there was already a bunch of functions designed specifically to avoid doing this in
droid.h
(get*Stats()
function family forDROID
). These places were patched to usegetStats()
functions, instead.There are still some places that do pointer arithmetic tricks (e.g., to get the component index back from the stat pointer), these will be fixed a bit later.
NOTE:
visibility.h
header include was removed fromdroid.h
to avoid cyclic dependency between header files, although we useobjSensorRange
function from it. So, it's declared asextern
indroid.h
. This is a dirty workaround and will also be fixed later.